from django.contrib import admin

from .models import Profile


# Register your models here.
@admin.register(Profile)
class ProfileAdmin(admin.ModelAdmin):
    # 列表中显示的字段
    list_display = ('uid', 'phone', 'user', 'is_upgrade', 'upgrade_count')
    # 支持搜索的字段（包含用户名字段）
    search_fields = ('uid', 'phone', 'user__username')
    # 右侧过滤器
    list_filter = ('is_upgrade', 'expire_time')
    # 每页显示数量
    list_per_page = 20
    # 显示外键详情（用户字段）
    raw_id_fields = ('user',)
    # 多对多字段优化显示
    filter_horizontal = ('collect_books', 'owned_books')